<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

namespace app\common\model;

use think\Model as ThinkModel;

//银行列表模型
class Store extends ThinkModel
{
    // 设置当前模型对应的完整数据表名称
    protected $table = '__QT_STORE__';
    protected $name = 'qt_store';
    protected $pk = 'id';
    protected $autoWriteTimestamp = true;

    /**
     * 检测用户登录状态
     * @param $data
     * @return int
     */
    public  function checkUser($data){
        $userInfo = $this->where('phone',$data['phone'])->find();
        if($userInfo){
            //用户被禁用
            if($userInfo->status == 1){return 10002;}
            //对比密码
            $getPassword = pwd($data['password'],$userInfo->ivt_code);
            if($getPassword == $userInfo->password){
                return 2000;
            }else{
                //账号密码错误
                return 10003;
            }
        }
        //用户不存在请去登录
        return 10001;
    }

    /**
     *  获取门店信息
     * @param  int  $store_id  门店ID
    **/
    public static function getStoreInfo($store_id)
    {
        if(!$store_id)
        {
            return false;
        }

        $info = self::where('id',$store_id)->find();

        return $info;
    }


}